import React, { Component } from "react";
import MainLayout from "@component/mainLayout/mainLayout";
import "./../bankList/index.scss";
import "./index.scss";
import yhTools from "@tools/yh";
import Card from "./../bankList/card";

class BankInfo extends Component {
	constructor(props) {
		super(props);
		this.state = {
			bankCardInfo: {}
		};
	}
	componentDidMount() {
		let accountNoEncrypt = yhTools.getUrlParam("accountNo"),
			bankMobilePhone = yhTools.getUrlParam("bankMobilePhone"),
			bankName = decodeURIComponent(yhTools.getUrlParam("bankName")), //解决地址取参中文乱码
			id = yhTools.getUrlParam("id"),
			logUrl = yhTools.getUrlParam("logUrl"),
			singleLimitAmt = yhTools.getUrlParam("singleLimitAmt"),
			dayLimitAmt = yhTools.getUrlParam("dayLimitAmt");
		this.setState({
			bankCardInfo: {
				accountNoEncrypt,
				bankMobilePhone,
				bankName,
				id,
				logUrl,
				singleLimitAmt,
				dayLimitAmt
			}
		});
	}
	/**
	 * 解除绑定银行卡
	 */
	handleUnboundBank = () => {
		let { bankCardInfo } = this.state;
		this.props.history.push(
			`/unBindBank?id=${bankCardInfo.id}&&mobile=${bankCardInfo.bankMobilePhone}`
		);
	};
	render() {
		const { bankCardInfo } = this.state;
		const _pageParams = {
			header: {
				title: "银行卡"
			},
			history: this.props.history,
			cacheLifecycles: this.props.cacheLifecycles
		};
		return (
			<MainLayout pageParams={_pageParams}>
				<div className="bank-info-container">
					<Card item={bankCardInfo} onClick={() => {}} key={Math.random()} />
					<div className="unband-btn" onClick={this.handleUnboundBank}>
						解绑银行卡
					</div>
				</div>
			</MainLayout>
		);
	}
}

export default BankInfo;
